package com.example.kaoshi;

import java.util.ArrayList;
import java.util.Arrays;
import java.util.HashSet;
import java.util.Scanner;

/**
 * Created by Quincy on 2018/10/11.
 */
public class ContinueArray {

    private static ArrayList<HashSet<Integer>> lists = new ArrayList<>();
    private static int value = 0;

    public static void main(String[] args){
        Scanner scanner = new Scanner(System.in);
        String s = scanner.nextLine();
        String[] str = s.split(",");
        int len = str.length;
        int[] arr = new int[len];
        for (int i = 0; i < len; i++)
            arr[i] = Integer.parseInt(str[i]);
        Arrays.sort(arr);
        System.out.println(beauty_of_array(arr));
    }
    /**
     * 大体思路：
     * 1. 将数组排序
     * 2. 求出所有子序列，并把其放入set集合中
     * 3. 遍历set集合
     * */
    private static int beauty_of_array(int[] array){
        for(int i = 0;i<array.length;i++){
            for(int j = i+1;j<array.length;j++){
                HashSet<Integer> set = new HashSet<>();
                int count = j - i + 1;
                int[] cArray = new int[count];
                System.arraycopy(array,i,cArray,0,count);
                for (int ii:cArray)
                    set.add(ii);
                lists.add(set);
            }
        }
        return sum() + arrsum(array);
    }
    //求所有子序列的和
    private static int sum(){
        for (HashSet<Integer> set : lists)
            for (int i : set)
                value+=i;
        return value;
    }
    //单个元素的和
    private static int arrsum(int[] arr){
        int sum0 = 0;
        for (int i = 0; i < arr.length; i++)
            sum0 += arr[i];
        return sum0;
    }
}
